<?php
$messages['default'] = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->setNamespace()->getMessages();
$messages['success'] = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->setNamespace('success')->getMessages();
$messages['warnings'] = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->setNamespace('warnings')->getMessages();
$messages['errors'] = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->setNamespace('errors')->getMessages();

$js = '';

if (!empty($messages['default']))
{
	foreach ($messages['default'] as $v) {$js .= "$.n('" . str_replace("'", '"', $v) . "');\n";}
}
if (!empty($messages['success']))
{
	foreach ($messages['success'] as $v) {$js .= "$.n.success('" . str_replace("'", '"', $v) . "');\n";}
}
if (!empty($messages['warnings']))
{
	foreach ($messages['warnings'] as $v) {$js .= "$.n.warning('" . str_replace("'", '"', $v) . "');\n";}
}
if (!empty($messages['errors']))
{
	foreach ($messages['errors'] as $v) {$js .= "$.n.error('" . str_replace("'", '"', $v) . "');\n";}
}
#$js = "$.n('test!');"; // test!
$js = "$(document).ready(function () {\n" . $js . "\n});\n"; // TODO: jquery helper!
echo $js;
?>